<?php

/**
 * This is the model class for table "user_details".
 *
 * The followings are the available columns in table 'user_details':
 * @property integer $id
 * @property integer $content_id
 * @property string $name
 * @property string $email
 * @property integer $birth_year
 * @property string $address
 * @property integer $postcode
 * @property string $state
 * @property string $about
 * @property string $videopath
 * @property string $update_aus_tal
 * @property string $update_aus_app
 * @property string $term_cond
 * @property string $download
 */
class UserDetails extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return UserDetails the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'user_details';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('content_id, name, email, birth_year, address, postcode, state, about, videopath, update_aus_tal, update_aus_app, term_cond', 'required'),
			array('content_id, birth_year, postcode', 'numerical', 'integerOnly'=>true),
			array('name, email', 'length', 'max'=>100),
			array('state', 'length', 'max'=>50),
			array('videopath', 'length', 'max'=>500),
			array('update_aus_tal, update_aus_app, term_cond', 'length', 'max'=>1),
			array('download', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, content_id, name, email, birth_year, address, postcode, state, about, videopath, update_aus_tal, update_aus_app, term_cond, download', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'votes' => array(self::HAS_ONE, 'Votes', 'user_details_id')
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'content_id' => 'Content',
			'name' => 'Name',
			'email' => 'Email',
			'birth_year' => 'Birth Year',
			'address' => 'Address',
			'postcode' => 'Postcode',
			'state' => 'State',
			'about' => 'About',
			'videopath' => 'Videopath',
			'update_aus_tal' => 'Update Aus Tal',
			'update_aus_app' => 'Update Aus App',
			'term_cond' => 'Term Cond',
			'download' => 'Download',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('content_id',$this->content_id);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('birth_year',$this->birth_year);
		$criteria->compare('address',$this->address,false);
		$criteria->compare('postcode',$this->postcode);
		$criteria->compare('state',$this->state,true);
		$criteria->compare('about',$this->about,true);
		$criteria->compare('videopath',$this->videopath,true);
		$criteria->compare('update_aus_tal',$this->update_aus_tal,true);
		$criteria->compare('update_aus_app',$this->update_aus_app,true);
		//$criteria->compare('term_cond',$this->term_cond,true);
		//$criteria->compare('download',$this->download,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}